package cn.usian.basicInformation.city.controller;

import cn.usian.basicInformation.city.service.ICityService;
import cn.usian.basicInformation.log.commons.Constants;
import cn.usian.basicInformation.log.commons.Log;
import cn.usian.dto.basicInformation.city.BaseCityGradeManageDto;
import cn.usian.pojo.Result;
import cn.usian.pojo.basicInformation.city.BaseCityGrade;
import cn.usian.pojo.basicInformation.city.BaseCityGradeManage;
import cn.usian.vo.basicInformation.city.BaseCityGradeManageVo;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/city")
@RestController
@Slf4j
public class CityController {
    @Autowired
    private ICityService cityService;

    @GetMapping("/list")
    public Result list(BaseCityGradeManageDto cityGradeManageDto){
        log.info("baseCityGradeManage:{}",cityGradeManageDto);
        PageInfo<BaseCityGradeManageVo> cityList = cityService.list(cityGradeManageDto);
        return Result.ok(cityList);
    }

    @GetMapping("/cityGrade/list")
    public Result findCityGradeList(){
        List<BaseCityGrade> cityGradeList = cityService.cityGradeList();
        return Result.ok(cityGradeList);
    }

    @PostMapping("/save")
    @Log(operationModule = "城市等级配置", operationType = Constants.UPDATE)
    public Result save(@RequestBody BaseCityGradeManage baseCityGradeManage){
        log.info("baseCityGradeManage:{}",baseCityGradeManage);
        cityService.save(baseCityGradeManage);
        return Result.ok();
    }


}
